package daos;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;

public class Conexao {

	private Connection con;
	
	private void abrirConexao(){
		
		
		try{

			Class.forName("com.mysql.jdbc.Driver");
			con = DriverManager.getConnection("jdbc:mysql://localhost:3306/jfreedom_showcase","root","sarai");
			
		}catch(SQLException a){
			a.printStackTrace();
		}
		catch(ClassNotFoundException a){
			a.printStackTrace();
		}
		
	}
	
	public Connection getConexao(){
		
		if(con == null){
			abrirConexao();
		}
		
		return con;
	}
	
	public void shutDown() throws SQLException{
		if(con != null){
			con.close();
		}
	}
}
